package com.coder520.user.controller;

import com.coder520.user.entity.User;
import com.coder520.user.service.UserService;
import com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIConversion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/home")
    public String home(){

        return "home";
    }

    /**
     * @Author: Lin
     * @Param:  * @param session
     * @Description: AJAX异步查询用户信息方法
     * @Date: 19:06 2017/9/13
     */
    @RequestMapping("/userinfo")
    @ResponseBody
    public User getUser(HttpSession session){

        User user = (User) session.getAttribute("user");

        return user;
    }

    /**
     * @Author: Lin
     * @Param:  * @param session
     * @Description: 注销账户登录
     * @Date: 19:12 2017/9/13
     */
    @RequestMapping("/logout")
    public String logout(HttpSession session){

        session.invalidate();

        return "login";
    }
}
